package crypto.util;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;

/**
 * DOCUMENT ME!
 *
 * @author gato
 */
public class FileManager {
  /**
   * DOCUMENT ME!
   *
   * @param content DOCUMENT ME!
   * @param fileName DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public static boolean saveFile(String content, String fileName) {
    try {
      File        file  = new File(fileName);
      PrintWriter print = new PrintWriter(file);

      print.write(content);
      print.close();
    } catch (java.io.IOException ioe) {
      return false;
    }

    return true;
  }

  /**
   * DOCUMENT ME!
   *
   * @param content DOCUMENT ME!
   * @param fileName DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public static boolean saveEncryptXML(String content, String fileName) {
    return true;
  }

  /**
   * DOCUMENT ME!
   *
   * @param fileName DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public static String readFile(String fileName) {
    String text = "";

    try {
      File                file = new File(fileName);
      FileInputStream     fis  = new FileInputStream(file);
      BufferedInputStream bis  = new BufferedInputStream(fis);
      DataInputStream     dis  = new DataInputStream(bis);

      text                     = dis.readLine();
    } catch (java.io.IOException ioe) {
      ioe.printStackTrace();

      return null;
    }

    return text;
  }
}
